package org.example.mall.Config;

import org.example.mall.Interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).excludePathPatterns(
                "/User/Login",
                "/User/Register",
                "/product/detail",
                "/product/preview",
                "/product/previewbypid"
                );
        //使用注册器registry将拦截器注册进去
        //用户访问指定资源时放行，不会全部拦截
    }
}
